package com.bigfire.dtm.shared.exception;

import com.bigfire.dtm.shared.enums.ResponseCodeEnum;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Value;

/**
 * 业务相关异常类
 * @author Damon S.
 */
@Value
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
public class BusinessException extends RuntimeException {

    Integer code;

    public BusinessException(ResponseCodeEnum codeEnum) {
        super(codeEnum.getMessage());
        this.code = codeEnum.getCode();
    }

    public BusinessException(ResponseCodeEnum codeEnum, String message) {
        super(codeEnum.getMessage() + "：" + message);
        this.code = codeEnum.getCode();
    }

    @Override
    public String toString() {
        return super.toString() + super.getMessage();
    }
}

